package com.ljm.travels.service.serviceImpl;

import com.ljm.travels.dao.ProvinceDAO;
import com.ljm.travels.domain.Province;
import com.ljm.travels.service.ProvinceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional
public class ProvinceServiceImpl implements ProvinceService {
    @Autowired
    private ProvinceDAO provinceDAO;

    @Override
    public List<Province> findByPage(Integer page, Integer rows) {
        int start =(page-1)*rows;
        return provinceDAO.findByPage(start,rows);
    }

    @Override
    public Long findTotals() {
        return provinceDAO.findTotals();
    }

    @Override
    public void save(Province province) {
        province.setPlaceCounts(0);
        provinceDAO.save(province);
    }

    @Override
    public void update(Province province) {
        provinceDAO.update(province);
    }

    @Override
    public Province findOne(Integer id) {
        return provinceDAO.findOne(id);
    }

    @Override
    public void delete(Integer id) {
        provinceDAO.delete(id);
    }

    @Override
    public List<Province> findAll() {
        return provinceDAO.findAll();
    }
}
